<!DOCTYPE html>
<html lang="en"
      xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>新建作品</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" href="../../../static/images/favicon.ico" th:href="@{/images/favicon.ico}">
    <link rel="stylesheet" href="../../../static/plugin/layui/css/layui.css" th:href="@{/plugin/layui/css/layui.css}" media="all"/>
    <link rel="stylesheet" href="../../../static/back_css/create_works.css" th:href="@{/back_css/create_works.css}" media="all">
    <link rel="stylesheet" href="../../../static/back_css/create_activity.css" th:href="@{/back_css/create_activity.css}" media="all">
</head>
<body>
    <div style="width: 70%;height: 100%; margin-top: 100px;">
        <form class="layui-form" th:if="${prizeUser}==null">
            <div class="layui-form-item">
                <label class="layui-form-label">领奖地址</label>
                <div class="layui-input-block">
                    <input type="text" name="DISTRICT" lay-verify="required"  autocomplete="off" placeholder="请输入领奖地址" class="layui-input DISTRICT">
                </div>
            </div>

            <div class="layui-inline" style="margin-bottom: 30px;">
                <label class="layui-form-label label_color">领奖时间</label>
                <div class="layui-input-inline date_border">
                    <i class="layui-icon layui-icon-date"></i>
                    <input type="text" name="start_date" lay-verify="datetime"
                           placeholder="设置开始时间" autocomplete="off"
                           class="layui-input date global_start_time">
                </div>
                <div class="layui-input-inline date_border">
                    <i class="layui-icon layui-icon-date"></i>
                    <input type="text" name="end_date" lay-verify="datetime"
                           placeholder="设置结束时间" autocomplete="off"
                           class="layui-input date global_end_time">
                </div>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-block">
                    <input type="text" name="NOTE" lay-verify="required" autocomplete="off" placeholder="请输入备注" class="layui-input NOTE">
                </div>
            </div>
        </form>
        <form class="layui-form" th:if="${prizeUser}!=null">
            <div class="layui-form-item">
                <label class="layui-form-label">领奖地址</label>
                <div class="layui-input-block">
                    <input type="text" th:value="${prizeUser.getDISTRICT()}" name="DISTRICT" lay-verify="required"  autocomplete="off" placeholder="请输入领奖地址" class="layui-input DISTRICT">
                </div>
            </div>

            <div class="layui-inline" style="margin-bottom: 30px;">
                <label class="layui-form-label label_color">领奖时间</label>
                <div class="layui-input-inline date_border">
                    <i class="layui-icon layui-icon-date"></i>
                    <input type="text" name="start_date" lay-verify="datetime"
                           placeholder="设置开始时间" autocomplete="off"
                           class="layui-input date global_start_time" th:value="${prizeUser.getSTART()}">
                </div>
                <div class="layui-input-inline date_border">
                    <i class="layui-icon layui-icon-date"></i>
                    <input type="text" name="end_date" lay-verify="datetime"
                           placeholder="设置结束时间" autocomplete="off"
                           class="layui-input date global_end_time" th:value="${prizeUser.getEND()}">
                </div>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label">备注</label>
                <div class="layui-input-block">
                    <input type="text" name="NOTE" th:value="${prizeUser.getNOTE()}" lay-verify="required" autocomplete="off" placeholder="请输入备注" class="layui-input NOTE">
                </div>
            </div>
        </form>

        <div class="layui-form_bottom">
            <button type="button" class="layui-btn layui-btn-warm layui-btn-radius layui-bg-grays btn1_cancel">
                取消
            </button>
            <button type="button" lay-filter="sign" lay-submit
                    class="layui-btn layui-btn-warm layui-btn-radius layui-bg-oranges">提交
            </button>
        </div>



    </div>
<script type="text/javascript" src="../../../static/plugin/layui/layui.js" th:src="@{/plugin/layui/layui.js}"></script>
<script type="text/javascript">
    var laydate;
    var $;
    layui.use(['form', "laydate", "jquery", "element", 'layer'], function () {
        var form = layui.form,
            layer = layui.layer;
        var element = layui.element;
        $ = layui.jquery;
        laydate = layui.laydate;
        $.fn.serializeObject = function () {
            var o = {};
            var a = this.serializeArray();
            $.each(a, function () {
                if (o[this.name]) {
                    if (!o[this.name].push) {
                        o[this.name] = [o[this.name]];
                    }
                    o[this.name].push(this.value || '');
                } else {
                    o[this.name] = this.value || '';
                }
            });
            return o;
        }

        laydate.render({

            elem: $(".global_start_time")[0],
            type:'datetime',
            done: function (a, b, c) {
                if ($("#match_date_list").children().length != 0) {
                    $("#match_date_list").children().first().find(".date").first().val(a);
                    alert($("#global_start_time")[0])
                }
            }

        });
        laydate.render({
            elem: $(".global_end_time")[0],
            type:'datetime',
            done: function (a, b, c) {
                if ($("#match_date_list").children().length != 0) {
                    $("#match_date_list").children().last().find(".date").last().val(a);
                }
            }
        });
        $(".btn1_cancel").on("click", function () {
            window.history.back(-1);
        });


        form.on("submit(sign)", function (data) {
            var STARTTIME = $(".global_start_time").val();//开始时间
            var ENDTIME = $(".global_end_time").val();//开始时间
            var NOTE = $(".NOTE").val();
            var DISTRICT = $(".DISTRICT").val();
            if(DISTRICT==""||DISTRICT==null){
                layer.msg("请添加领奖地址！");
                return false;
            }
            if(STARTTIME==""||STARTTIME==null){
                layer.msg("请设置开始时间！");
                return false;
            }
            if(ENDTIME==""||ENDTIME==null){
                layer.msg("请设置结束时间！");
                return false;
            }
            if(NOTE==""||NOTE==null){
                layer.msg("请添加备注！");
                return false;
            }
            var formData = new FormData();
            formData.append("DISTRICT", DISTRICT);
            formData.append("NOTE", NOTE);
            formData.append("START", STARTTIME);
            formData.append("END", ENDTIME);
            $.ajax({
                url: '/upPrizeUser',
                type: 'POST',
                cache: false,
                data: formData,
                processData: false,
                contentType: false,
                success: function (result) {
                    window.location.href = '/workss';
                }
            })

        });
    })
</script>
</body>
</html>